/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ncrnadb.ncinetview.internal.ui;


import ncrnadb.ncinetview.internal.NcINetViewApp;
import ncrnadb.ncinetview.internal.cy.CyUtils;
import ncrnadb.ncinetview.internal.request.AllRequest;

import org.cytoscape.model.CyNetwork;

/**
 *
 * @author vbonnici
 */
public class ImportDBPanel extends javax.swing.JPanel {

    private QueryDialog parentToDispose = null;
    
    /**
     * Creates new form QueryFromSearch
     */
    public ImportDBPanel(QueryDialog parentToDispose) {
        initComponents();
        this.parentToDispose = parentToDispose;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        addRNA = new javax.swing.JCheckBox();
        addGene = new javax.swing.JCheckBox();
        addDisease = new javax.swing.JCheckBox();
        addOthers = new javax.swing.JCheckBox();
        jSeparator2 = new javax.swing.JSeparator();
        jButton4 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        netnameText = new javax.swing.JTextField();
        jSeparator4 = new javax.swing.JSeparator();

        jLabel1.setText("Relations types");

        jCheckBox1.setSelected(true);
        jCheckBox1.setText("ncRNA - ncRNA");
        jCheckBox1.setEnabled(false);

        addRNA.setText("ncRNA - RNA");

        addGene.setText("ncRNA - Gene");

        addDisease.setText("ncRNA - Disease");

        addOthers.setText("ncRNA - Others");

        jButton4.setText("Import");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel8.setText("Network name");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator4)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(netnameText))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(addGene)
                            .addComponent(jLabel1)
                            .addComponent(jCheckBox1)
                            .addComponent(jButton4)
                            .addComponent(addRNA)
                            .addComponent(addDisease)
                            .addComponent(addOthers))
                        .addGap(0, 331, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jSeparator2)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(netnameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBox1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addRNA)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addGene)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addDisease)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addOthers)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        String nname = this.netnameText.getText().trim();
        if(nname.length() > 0){
            CyNetwork net = NcINetViewApp.app().createNewNetwork(nname);
            AllRequest req = new AllRequest();
            req.network = net;

            req.addRNA = this.addRNA.isSelected();
            req.addGene = this.addGene.isSelected();
            req.addDisease = this.addDisease.isSelected();
            req.addOthers = this.addOthers.isSelected();
            
            req.solve();
        }
        this.parentToDispose.dispose();
    }//GEN-LAST:event_jButton4ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox addDisease;
    private javax.swing.JCheckBox addGene;
    private javax.swing.JCheckBox addOthers;
    private javax.swing.JCheckBox addRNA;
    private javax.swing.JButton jButton4;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextField netnameText;
    // End of variables declaration//GEN-END:variables
}
